<?php
    /**
    *file-level documentation
    *@author El-Hindi, Feil, Ziegler <goatymail@googlemail.com>
    *27 May 2012
    *@copyright Copyright (c) 2012, Tuncay Bakan
    *@package lib
    *
    */
    include_once(WEBSITE_ROOT.'lib/loader.class.php');
    /**
    *the class router analyzes the requests and instanciates the right controller
    */
    class Router{
        
        /**
         * takes the GET-parameters and calls the controller
         * @param Array $aRequest
         */
        public static function route($aRequest){
            //assign the first element of the array to sPage
             $sFirstElement= array_shift($aRequest);
                if($sFirstElement=="ajax"){
                    $oCInstance = Loader::loadController($aRequest['co']);   
                    if (method_exists($oCInstance,$aRequest['m'])){
                        $oCInstance->$aRequest['m']($_POST);
                    }
            }else{
          
            $aArgs = $aRequest;
            
            $oCInstance = Loader::loadController($sFirstElement);   
            $oCInstance->execute($aArgs);
            //$oViewmanager = Viewmanager::getInstance();
            //$oViewmanager->load();
            }
            
        }
    }

?>